﻿using System;
using System.Windows;
using System.Windows.Data;

namespace AnthStat.WPF.Applications.Converters
{
    public sealed class ChartYAxisStepConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if(values == null || values.Length != 2) 
            {
                return 1;
            }

            if (values[0] == null || values[0] == DependencyProperty.UnsetValue) { return 1; }
            if (values[1] == null || values[1] == DependencyProperty.UnsetValue) { return 1; }

            double start = (double)values[0];
            double end = (double)values[1];

            double difference = end - start;

            if (difference <= 30)
            {
                return 1.0;
            }
            else if (difference > 30 && difference <= 60)
            {
                return 5.0;
            }
            else
            {
                return 10.0;
            }
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
